package com.wit.example.util;

import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
import com.github.mikephil.charting.formatter.ValueFormatter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

public class CustomTimeAxisFormatter extends ValueFormatter {

    private SimpleDateFormat mFormat;

    public CustomTimeAxisFormatter() {
        mFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
    }

    @Override
    public String getFormattedValue(float value, AxisBase axis) {
        long millis = TimeUnit.SECONDS.toMillis((long) value);
        return mFormat.format(new Date(millis));
    }
}